package com.wuhuiyue.controller;


import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.util.DateUtils;
import com.wuhuiyue.entity.Group;
import com.wuhuiyue.entity.Result;
import com.wuhuiyue.entity.Seartch;
import com.wuhuiyue.service.IGroupService;
import com.wuhuiyue.service.ISoftwareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hy-woo
 * @since 2022-06-11
 */
@RestController
@RequestMapping("/group")
public class GroupController {

    @Autowired
    IGroupService groupService;

    @Autowired
    ISoftwareService softwareService;

    @RequestMapping("/countByGid")
    public Result countByGid(@RequestBody Seartch seartch){
        if (seartch.getDatea()!=null && seartch.getDateb()!=null){
            List<Group> groupList=softwareService.countByGid(seartch.getDatea(),seartch.getDateb());
            return Result.OK(groupList);
        }
        seartch.setDatea(DateUtil.parse("1912-12-1"));
        seartch.setDateb(DateUtil.parse("2100-1-3"));
        List<Group> groupList=softwareService.countByGid(seartch.getDatea(),seartch.getDateb());
        return Result.OK(groupList);
    }

    @RequestMapping("/groupList")
    public Result groupList(){
        List<Group> list = groupService.list();
        return Result.OK(list);
    }

}
